ti: k3: drivers: ti_sci: Use non-blocking TI-SCI messages for power down
authorAndrew F. Davis <[email protected]>
Mon, 11 Feb 2019 20:37:58 +0000 (14:37 -0600)
committerAndrew F. Davis <[email protected]>
Mon, 11 Feb 2019 22:13:30 +0000 (16:13 -0600)
Now that we have non-blocking TI-SCI functions we can initiate the shutdown
sequence from the PSCI handler without needing the ti_sci_proc_shutdown
helper function, which is removed. This gives us the greater control and
flexibility that will be needed when cluster power down sequences are added.

Signed-off-by: Andrew F. Davis <[email protected]>
plat/ti/k3/common/drivers/ti_sci/ti_sci.c
plat/ti/k3/common/drivers/ti_sci/ti_sci.h
plat/ti/k3/common/k3_psci.c

index 0f0a6f0c328009d59b7944745a197c42bb14a9a5..df0b794f854847a759c5ff4ad41e3841555f9ad9 100644 (file)
@@ -1680,88 +1680,6 @@ int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id,
        return 0;
 }
 
-/**
- * ti_sci_proc_shutdown() - Shutdown Processor without waiting for ACKs
- *
- * @proc_id:   Processor ID this request is for
- * @dev_id:    Device identifier this request is for
- *
- * Return: 0 if all goes well, else appropriate error message
- */
-int ti_sci_proc_shutdown(uint8_t proc_id, uint32_t dev_id)
-{
-       struct ti_sci_msg_req_wait_proc_boot_status wait_req;
-       struct ti_sci_msg_req_set_device_state set_req;
-       /*
-        * We will not be waiting for this response, but declare one anyway
-        * to pass to the setup function so the checks will still pass
-        */
-       struct ti_sci_msg_hdr resp;
-
-       struct ti_sci_xfer xfer;
-       int ret;
-
-       /* Start by sending wait command */
-
-       /* Setup with NORESPONSE flag to keep response queue clean */
-       ret = ti_sci_setup_one_xfer(TISCI_MSG_WAIT_PROC_BOOT_STATUS,
-                                   TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
-                                   &wait_req, sizeof(wait_req),
-                                   &resp, sizeof(resp),
-                                   &xfer);
-       if (ret) {
-               ERROR("Message alloc failed (%d)\n", ret);
-               return ret;
-       }
-
-       wait_req.processor_id = proc_id;
-       /*
-        * Wait maximum time to give us the best chance to get
-        * to WFI before this command timeouts
-        */
-       wait_req.delay_before_iterations_us = UINT8_MAX;
-       wait_req.num_wait_iterations = UINT8_MAX;
-       wait_req.delay_per_iteration_us = UINT8_MAX;  /* TODO: optimize time */
-       wait_req.num_match_iterations = 2;
-       wait_req.status_flags_1_set_all_wait = 0;
-       /* Wait for either WFE or WFI */
-       wait_req.status_flags_1_set_any_wait = PROC_BOOT_STATUS_FLAG_ARMV8_WFE |
-                                              PROC_BOOT_STATUS_FLAG_ARMV8_WFI;
-       wait_req.status_flags_1_clr_all_wait = 0;
-       wait_req.status_flags_1_clr_any_wait = 0;
-
-       /* Send wait message */
-       ret = k3_sec_proxy_send(SP_HIGH_PRIORITY, &xfer.tx_message);
-       if (ret) {
-               ERROR("Message sending failed (%d)\n", ret);
-               return ret;
-       }
-
-       /* Now queue up the shutdown request */
-       ret = ti_sci_setup_one_xfer(TI_SCI_MSG_SET_DEVICE_STATE,
-                                   TI_SCI_FLAG_REQ_GENERIC_NORESPONSE,
-                                   &set_req, sizeof(set_req),
-                                   &resp, sizeof(resp),
-                                   &xfer);
-       if (ret) {
-               ERROR("Message alloc failed (%d)\n", ret);
-               return ret;
-       }
-
-       set_req.id = dev_id;
-       set_req.state = MSG_DEVICE_SW_STATE_AUTO_OFF;
-
-       /* Send shutdown message */
-       ret = k3_sec_proxy_send(SP_HIGH_PRIORITY, &xfer.tx_message);
-       if (ret) {
-               ERROR("Message sending failed (%d)\n", ret);
-               return ret;
-       }
-
-       /* Return without waiting for responses */
-       return 0;
-}
-
 /**
  * ti_sci_init() - Basic initialization
  *
index a179c13210bfaaf24acc2f6370970f2c60089446..c7b09b30d55e4045fc57d640f3c0b91113bfa4de 100644 (file)
@@ -205,7 +205,6 @@ int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id,
                                         uint32_t status_flags_1_set_any_wait,
                                         uint32_t status_flags_1_clr_all_wait,
                                         uint32_t status_flags_1_clr_any_wait);
-int ti_sci_proc_shutdown(uint8_t proc_id, uint32_t dev_id);
 
 /**
  * ti_sci_init() - Basic initialization
index 235e6396b6f1f564ae934de841754e368a162f81..afe465e56b65dd5b6f59e592782e96997eb190ba 100644 (file)
@@ -13,6 +13,7 @@
 #include <lib/psci/psci.h>
 #include <plat/common/platform.h>
 
+#include <ti_sci_protocol.h>
 #include <k3_gicv3.h>
 #include <ti_sci.h>
 
@@ -90,9 +91,24 @@ void k3_pwr_domain_off(const psci_power_state_t *target_state)
        proc = PLAT_PROC_START_ID + core_id;
        device = PLAT_PROC_DEVICE_START_ID + core_id;
 
-       ret = ti_sci_proc_shutdown(proc, device);
+       /* Start by sending wait for WFI command */
+       ret = ti_sci_proc_wait_boot_status_no_wait(proc,
+                       /*
+                        * Wait maximum time to give us the best chance to get
+                        * to WFI before this command timeouts
+                        */
+                       UINT8_MAX, 100, UINT8_MAX, UINT8_MAX,
+                       /* Wait for WFI */
+                       PROC_BOOT_STATUS_FLAG_ARMV8_WFI, 0, 0, 0);
        if (ret) {
-               ERROR("Request to stop core failed: %d\n", ret);
+               ERROR("Sending wait for WFI failed (%d)\n", ret);
+               return;
+       }
+
+       /* Now queue up the core shutdown request */
+       ret = ti_sci_device_put_no_wait(device);
+       if (ret) {
+               ERROR("Sending core shutdown message failed (%d)\n", ret);
                return;
        }
 }